using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Network;
using MicroMsg.Protocol;
using MicroMsg.Scene;
using System;
namespace MicroMsg.Plugin.Shake.Scene
{
	public class NetSceneShakeReport : NetSceneBaseEx<ShakeReportRequest, ShakeReportResponse, ShakeReportRequest.Builder>
	{
		private const string TAG = "NetSceneShakeReport";
		public bool doScene(double latitude, double longitude)
		{
			Log.smethod_4("NetSceneShakeReport", "doscene in");
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.OpCode = 0u;
			this.mBuilder.Latitude = (float)latitude;
			this.mBuilder.Longitude = (float)longitude;
			this.mBuilder.Precision = 0;
			this.mBuilder.ImgId = ConfigMgr.smethod_0<ShakeConfig>().nShakeImgID;
			this.mBuilder.Times = 1u;
			this.mSessionPack.mCmdID = 56;
			base.endBuilder();
			return true;
		}
		protected override void onFailed(ShakeReportRequest request, ShakeReportResponse response)
		{
			PackResult lastError = base.getLastError();
			Log.smethod_4("NetSceneShakeReport", "onFailed in PackResult =" + lastError);
			if (lastError == PackResult.BEEN_CANCELLED)
			{
				return;
			}
			EventCenter.postEvent(EventConst.ON_NETSCENE_SHAKE_ERR, null, null);
		}
		protected override void onSuccess(ShakeReportRequest request, ShakeReportResponse response)
		{
			Log.smethod_4("NetSceneShakeReport", "onSuccess in");
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret != RetConst.MM_OK)
			{
				EventCenter.postEvent(EventConst.ON_NETSCENE_SHAKE_ERR, null, null);
				return;
			}
			Shake.getInstance().sceneShakeService.mSceneShakeGet = new NetSceneShakeGet();
			Shake.getInstance().sceneShakeService.mSceneShakeGet.doScene(response.Buffer);
			if (ConfigMgr.smethod_0<ShakeConfig>().bShakeCustomImg)
			{
				return;
			}
			if (ConfigMgr.smethod_0<ShakeConfig>().nShakeImgID == response.ImgId)
			{
				return;
			}
			NetSceneShakeImg netSceneShakeImg = new NetSceneShakeImg();
			netSceneShakeImg.doScene(response.ImgId, response.ImgTotoalLen);
		}
	}
}
